import {createSlice} from "@reduxjs/toolkit";

const countStore = createSlice({
    name: 'countId',
    initialState: {
        userName: 'admin',
        count: 0,
        age: 20
    },
    reducers: {
        exitName: (state) => {
            state.userName = 'common'
        },
        exitAge: (state) => {
            state.age = 24
        },
        addCount: (state) => {
            state.count++
        },
        subCount: (state) => {
            state.count--
        },
        addNum(state,action){
            state.count= state.count + action.payload
        }
    }
})
const {exitName, exitAge, addCount, subCount,addNum} = countStore.actions
const reducer = countStore.reducer
export {exitName, exitAge, addCount, subCount,addNum}
export default reducer
